<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>

<script src="JS/jquery-2.1.0.min.js"></script>

<script>
	$(document).ready(function(){
		$("#ajaxPost").click(function(){
			var json ='{"age":22,"apellido2":"pepe","firstName":"Agamenon","id":1,"lastName":"Diaz","phone":"6666666"}'//JSON.stringify({"firstName": "Raul", "age": 32,"apellido2":"Vega", "lastName":"Navascues","Phone":"666555444","id":1}); 
			//alert("hola")//{"age":22,"apellido2":"pepe","firstName":"Agamenon","id":1,"lastName":"Diaz","phone":"6666666"};
			$.ajax({
				url: "rest/hello/",
				type: "post",
				data: json,
				dataType:"json",
				processdata: true,
				contentType: "application/json; charset=utf-8",
				success: function(){},
				error: function(jqXHR, textStatus, errorThrown){ alert('update send error: ' + textStatus + "\n" + errorThrown); }
			});		
		});		
	});
	
</script>

	<link href="css/highlight.default.css" rel="stylesheet" type="text/css" />
	<link href="css/screen.css" rel="stylesheet" type="text/css" />
  <script type="text/javascript" src="lib/shred.bundle.js"></script>
  <script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
  <script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
  <script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
  <script src='lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
  <script src='lib/handlebars-1.0.0.js' type='text/javascript'></script>
  <script src='lib/underscore-min.js' type='text/javascript'></script>
  <script src='lib/backbone-min.js' type='text/javascript'></script>
  <script src='lib/swagger.js' type='text/javascript'></script>
  <script src='swagger-ui.js' type='text/javascript'></script>
  <script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
  <script type="text/javascript">
    $(function () {
      window.swaggerUi = new SwaggerUi({
      url: "http://localhost:8080/PruebaRestfullSM/rest/api-docs",
      dom_id: "swagger-ui-container",
      supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
      onComplete: function(swaggerApi, swaggerUi){
        log("Loaded SwaggerUI")
        $('pre code').each(function(i, e) {hljs.highlightBlock(e)});
      },
      onFailure: function(data) {
        log("Unable to Load SwaggerUI");
      },
      docExpansion: "none"
    });

    $('#input_apiKey').change(function() {
      var key = $('#input_apiKey')[0].value;
      log("key: " + key);
      if(key && key.trim() != "") {
        log("added key " + key);
        window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
      }
    })
    window.swaggerUi.load();
  });

  </script>


</head>
<body>
	<a href='rest/hello/'>Enlace</a>
	<button id="ajaxPost">Llamada Ajax Post</button>
	
<div id="message-bar" class="swagger-ui-wrap">
  &nbsp;
</div>

<div id="swagger-ui-container" class="swagger-ui-wrap">

</div>
</body>
</html>